<?php 
    $currChapter = $chapter[0]['chapter'];
    $lstChapter = $novel->chapter[0];
?>
<div class="chapter-navi" class="row">
    <span class="menu-button" id="tblcontents"><i class="fa fa-bars"></i></span>
    <?php if ($currChapter > 1 || $currChapter < $lstChapter['chapter']) { ?>
    <nav>
        <?php if ($currChapter > 1) { ?>
            <a href="<?=base_url()?>truyen/<?=$novel->slug?>/chuong/<?=$currChapter - 1?>" id="bb-nav-prev" class="bb-nav-prev" style="display: block;">←</a>
        <?php }?>
        <?php if ($currChapter < $lstChapter['chapter']) { ?>
            <a href="<?=base_url()?>truyen/<?=$novel->slug?>/chuong/<?=$currChapter + 1?>" id="bb-nav-next" class="bb-nav-next" style="display: block;">→</a>
        <?php }?>
    </nav>
    <?php } ?>
    <div class="navi-title">
        <form class="form-inline" role="form">
            <select class="form-control input-sm hidden-xs chapterSelect" onchange="window.location = this.options[this.selectedIndex].value;">
                <?php foreach ($novel->chapter as $c): $url = '/truyen/' . $novel->slug . '/chuong/' . $c['chapter']; ?>
                    <option value="<?= $url ?>" <?= $currChapter == $c['chapter'] ? 'selected' : '' ?>>
                        Chương <?= $c['chapter'] ?><?= $c['title'] ? ' - ' . $c['title'] : '' ?>
                    </option>
                <?php endforeach; ?>
            </select>
            <h2 class="pull-left hidden-xs top-title">
                <a href="<?=base_url()?>truyen/<?=$novel->slug?>"><?=$novel->name;?></a>
            </h2>
        </form>
    </div>
</div>
<div class="col-md-12 col-sm-12 col-lg-10 chapter-content">
    <h2 class="chapter-title">
        Chương <?=$currChapter . ($chapter[0]['title'] ? ' - ' . $chapter[0]['title'] : '') ?>
    </h2>
    <div class="chapter-detail">
        <?=$chapter[0]['content']?>
    </div>
    <div id="fb-root"></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1&appId=1421394131449804";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    <div class="fb-comments" data-href="<?=base_url()?>truyen/<?=$novel->slug?>/chuong/<?=$currChapter?>" data-numposts="50" data-colorscheme="light"></div>
</div>